//  Copyright (c) 2008  Yoong-ki Ahn & Youngjin Kim < mexif@googlegroups.com>
//  See the enclosed file COPYING for license information (MIT Licence).
//  If you did not receive this file,
//  see http://www.opensource.org/licenses/mit-license.php.

#ifndef __MEXIF_EXIF_H__
#define __MEXIF_EXIF_H__

#ifdef __cplusplus
extern "C"
{
#endif

/// @return MEXIF_RET_OK if exif is valid "EXIF" data structure.
/// MEXIF_RET_MISSING_EXIF_HEADER for invalid exif header. "Exif\0\0" must be prefixed.
/// MEXIF_RET_MISSING_TIFF_HEADER for invalid tiff header.
mexif_return_t  MEXIF_API mexif_exif_init(  mexif_exif_t* exif, const void* data, unsigned int size );
void			MEXIF_API mexif_exif_close( mexif_exif_t* exif );

/// adjust makernote.
/// @return MEXIF_RET_OK for no error.
mexif_return_t  MEXIF_API mexif_recognize_makernote( mexif_exif_t* exif );


/// parsing welknown section.
mexif_return_t  MEXIF_API mexif_section_select( mexif_section_t* section, mexif_exif_t* exif, mexif_section_type_t type );
void			MEXIF_API mexif_section_close( mexif_section_t* section );

mexif_uint32	MEXIF_API mexif_count_tags( mexif_section_t* section );
mexif_return_t  MEXIF_API mexif_search_tag( mexif_section_t* section, mexif_tag_t* tag, mexif_uint32 tagid );
mexif_return_t  MEXIF_API mexif_select_tag( mexif_section_t* section, mexif_tag_t* tag, mexif_uint32 index );

mexif_return_t  MEXIF_API mexif_subsection_load( mexif_section_t* section, mexif_tag_t* tag );

mexif_uint32	MEXIF_API mexif_tag_value_uint( mexif_tag_t* tag );
mexif_int32		MEXIF_API mexif_tag_value_int(  mexif_tag_t* tag );
mexif_uint32	MEXIF_API mexif_tag_value_uint_index( mexif_tag_t* tag, mexif_uint32 index );
mexif_int32		MEXIF_API mexif_tag_value_int_index(  mexif_tag_t* tag, mexif_uint32 index );
double			MEXIF_API mexif_tag_value_double( mexif_tag_t* tag );
double			MEXIF_API mexif_tag_value_double_index( mexif_tag_t* tag, unsigned int index );
mexif_pcstr		MEXIF_API mexif_tag_name( mexif_tag_t* tag );

/// parse value as time
mexif_return_t  MEXIF_API mexif_tag_value_time( mexif_tag_t* tag, mexif_time_t* t );


#ifdef _MEXIFLIB_INSIDE
mexif_bool		__stdcall _mexif_is_ifd( mexif_format_t fmt );
mexif_bool		__stdcall _mexif_is_u8_array( mexif_format_t fmt );
mexif_bool		__stdcall _mexif_is_u16_array( mexif_format_t fmt );
mexif_bool		__stdcall _mexif_is_u32_array( mexif_format_t fmt );
mexif_uint32	__stdcall _mexif_ifd_count_tags( mexif_ifd_core_t* ifd );
mexif_format_t	__stdcall _mexif_get_subsection_format( mexif_section_t* section, mexif_tag_t* tag );
#endif


/// Rotation detected by Camera
mexif_rotate_t	MEXIF_API mexif_get_rotation( mexif_exif_t* exif );
mexif_return_t  MEXIF_API mexif_get_thumbnail( mexif_exif_t* exif, mexif_thumbnail_t* thumb );
mexif_return_t	MEXIF_API mexif_get_pictured_time( mexif_exif_t* exif, mexif_time_t* t );
mexif_bool		MEXIF_API mexif_has_gps_section( mexif_exif_t* exif );



#ifdef __cplusplus
}
#endif

#endif // __MEXIF_EXIF_H__
